package com.netease.easyexcel.service.impl;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.read.builder.ExcelReaderBuilder;
import com.alibaba.excel.read.builder.ExcelReaderSheetBuilder;
import com.netease.easyexcel.model.CellDetail;
import com.netease.easyexcel.service.ExcelParser;
import com.netease.easyexcel.util.ExcelReader;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import java.io.InputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;


@Service
public class ExcelParserImpl implements ExcelParser {
    @Override
    public void importByExcelFile(String serviceId, String ideVersion, MultipartFile[] xlsxFiles) {
        // 1. 将xlsx文件转化为String类型的字符串
        Map<String, String> xlsxFileString = new HashMap<>();
        for (MultipartFile file : xlsxFiles) {
            try {
                InputStream stream = file.getInputStream();

                ExcelReader excelReader = new ExcelReader();

                Map<String, List<CellDetail>> sheetDetailMap= excelReader.readExcelTitle(stream);

                Set<String> sheetNameSet = sheetDetailMap.keySet();
                //Map<Integer, String> integerStringMap = excelReader.readExcelContent(stream);

            } catch (Exception e) {
                e.printStackTrace();
            }
        }

/*        for (Map.Entry<String, String> xlsxStringEntry : xlsxFileString.entrySet()) {
            // 遍历 .xlsx 文件列表
            String sourceName = xlsxStringEntry.getKey();
            String tableInfoList = xlsxStringEntry.getValue();
            List<GraphEntityDto> parseTables = ParserExcelUtil.parseEntities(tableInfoList);
        }*/
    }
}
